/*
 * Project Name: showtao
 * File Name: VehicleLineRepository.java
 * Interface Name: VehicleLineRepository
 *
 * Copyright 2014 showtao.com
 *
 * Licensed under the showtao.com
 *
 * http://showtao.com
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.showtao.front.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.showtao.front.domain.VehicleLine;

public interface VehicleLineRepository extends
		JpaRepository<VehicleLine, Long>,
		JpaSpecificationExecutor<VehicleLine> {
    
    @Query("select v from VehicleLine v left join v.brand where v.id = :id")
    VehicleLine getOneJoinVehicleBrand(@Param("id")Long id);
    
    @Query("select v from VehicleLine v left join v.brand")
    Page<VehicleLine> findAllJoinVehicleBrand(Pageable pageable);
    
    @Query("select v from VehicleLine v left join v.models")
    List<VehicleLine> findAllJoinModels();
}
